package com.design.pattern.strategy.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 数据同步服务枚举
 * key对应syncconf里的conf_key
 * @author lisheng
 *
 */
public enum AddWorkerEnum {
	
	/**
	 * 默认的
	 */
	DEFAULT("0000000", "DEFAULT"),

	/**
	 * 测试1
	 */
	ONE("1000001", "ONE"),

	/**
	 * 测试2
	 */
	TWO("1000002", "TWO"),

	/**
	 * 测试3
	 */
	THREE("1000003", "THREE");

	
	private final String code;
	private final String module;
	
    private AddWorkerEnum(String code, String module) {
    	this.module = module;
    	this.code = code;
    }

	public String getModule() {
		return module;
	}

	public String getCode() {
		return code;
	}
	
	public static String getModuleByCode(String code) {
		if (StringUtils.isEmpty(code)) {
			return null;
		}
		
		for (OptionServiceEnum value: OptionServiceEnum.values()) {
			if (StringUtils.equals(code, value.getCode())) {
				return value.getModule();
			}
		}
		
		return null;
	}
}
